var zz = [
  '流口水',
  '不会咀嚼',
  '讲话晚',
  '胆小',
  '不会讲话'
]

var imgs = [
  'image/anli-li-1.jpg',
  'image/anli-li-2.jpg',
  'image/anli-li-3.jpg'
]

//获取地址中携带参数
var str = window.location.search.slice(-1)
console.log(str)

var itemD = document.querySelector('.item-d')

var xhr = new XMLHttpRequest()
xhr.open('get','http://47.116.75.38:8101/front/case?id='+str)
xhr.send(null)
xhr.onload = function () {
  var res = JSON.parse(xhr.response)
  console.log(res)
  res.data.records.forEach(function (item) {
    var h4 = document.createElement('h4')
    h4.innerText = zz[Math.floor(Math.random()*zz.length)]

    var p = document.createElement('p')
    p.className = 'd-p1'
    var i = document.createElement('i')
    i.className = 'iconfont icon-bianqian'
    var em = document.createElement('em')
    em.innerText = '成功案例'
    var i1 = document.createElement('i')
    i1.className = 'iconfont icon-yonghuzhongxinicon09'
    var span = document.createElement('span')
    span.innerText = item.caseTime

    p.appendChild(i)
    p.appendChild(em)
    p.appendChild(i1)
    p.appendChild(span)

    var img = document.createElement('img')
    img.src = imgs[Math.floor(Math.random()*imgs.length)]
    var lii = document.createElement('i')
    var lii1 = document.createElement('i')
    var lii2 = document.createElement('i')

    var ul = document.createElement('ul')
    var li = document.createElement('li')
    li.appendChild(lii)
    li.innerText = item.patientName +' ' + item.patientSex + ' ' + item.patientAge+'岁'
    var li1 = document.createElement('li')
    li1.appendChild(lii1)
    li1.innerText = '已上课时|'+item.courseTime
    var li2 = document.createElement('li')
    li2.appendChild(lii2)
    li2.innerText = '临床诊断|'+item.clinicalDiagnosis

    ul.appendChild(li)
    ul.appendChild(li1)
    ul.appendChild(li2)

    var h3 = document.createElement('h3')
    var span1 = document.createElement('span')
    span1.innerText = '治疗室日记'
    var a = document.createElement('a')
    a.innerText = '咨询沟通'

    h3.appendChild(span1)
    h3.appendChild(a)

    var p1 = document.createElement('p')
    p1.innerText = item.treatmentDiary

    itemD.appendChild(h4)
    itemD.appendChild(p)
    itemD.appendChild(img)
    itemD.appendChild(ul)
    itemD.appendChild(h3)
    itemD.appendChild(p1)
  })
}
